package process_demo.review.other_locks.about_vector;

/**
 * 2. 锁粗化
 * @author haomin
 * @date 2022/09/20 18:16
 **/
public class Main2 {
    static class MyThread extends Thread{
        int i = 0;
        // 加锁粒度过细，性能较低
        @Override
        public synchronized void run() {
            i++;
        }
    }
    static class MyThread2 extends Thread{
        int i = 0;
        // 加锁粒度适中，提升性能
        @Override
        public synchronized void run() {
            i++;
            i++;
            i++;
        }
    }
}